package com.qk.management.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @Author: ZgYn
 * @Date 2025/10/8 15:33
 * @name：FileHandleController
 */

@Slf4j
@RestController
public class FileHandleController {
    @PostMapping("/upload1")
    public String upload(String username, Integer age, @RequestParam("file")MultipartFile file) throws IOException {
        log.info("文件的原始名称：{}",  file.getOriginalFilename());
        log.info("文件类型：{}",  file.getContentType());
        log.info("文件大小：{}字节",  file.getSize());
        log.info("获取文件表单项提交name属性值：{}",  file.getName());
        log.info("文件是否为空：{}",  file.isEmpty());
        file.transferTo(new File("F:/" + file.getOriginalFilename()));
        return "上传成功";
    }
}
